﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using LumiSoft.Net;
using TEL.ClientClasses.Private;
using TEL.ClientClasses.SipInterfaces;

namespace TEL.ClientClasses
{
   public class SipSetting
   {
       public ISipAccount Propery { get; private set; }

       public SipSetting(ISipAccount propery)
       {
           Propery = propery;
       }
        #region Авторизация
       public string AOR
        {
            get
            {
                return string.Format("{0}@{1}:{2}", Propery.UserNumder,
                                     Propery.Host, 0);
            }
        }

        public string SIPServer
        {
            get
            {
                return string.Format("SIP:{0}:{1}", Propery.Host, Propery.Port);
            }
        }
       
        public bool Register { get; set; }

        public List<IPBindInfo> GetIPBindInfo()
        {
            List<IPBindInfo> res = new List<IPBindInfo>();
            res.Add(new IPBindInfo(
                        "",
                        (BindInfoProtocol)Enum.Parse(typeof(BindInfoProtocol), Propery.Transport),
                        IPAddress.Parse("0.0.0.0"),
                        0));

            res.Add(new IPBindInfo(
                        "",
                        (BindInfoProtocol) Enum.Parse(typeof (BindInfoProtocol), "TCP"),
                        IPAddress.Parse("0.0.0.0"),
                      0));

            return res;
        }

       public List<NetworkCredential> GetNetworkCredential()
        {
            List<NetworkCredential> res = new List<NetworkCredential>();
            res.Add(new NetworkCredential(
                Propery.UserName,
                Propery.Password,
                Propery.Host));

            return res;
        }

        public Account GetAccount()
        {
            return new Account(Propery.UserName, Propery.UserNumder.ToString(),
                               AOR, false, "", Register, SIPServer, 30, "");
        }
       #endregion
   }
}
